<template>
    <a-layout id="components-layout-demo-top" class="layout">
      <com-header></com-header>
      <a-layout-content class="container">
        <com-banner style="margin: 20px 0; padding: 20px;background: #FFF" :list="content.banner" />
        <card-content v-for="cover in content.lists"
                      :key="cover.classify"
                      :content="cover"
                      :title="cover.title"
                      show-category-type
                      :page-type="types.filter(el => el.name === cover.title)[0].key"
                      :category-type="category_type.filter(el => el.name === cover.title)[0] || {}">
          <com-title :title="cover.title"
                     :to="`category-type?page_type=${types.filter(el => el.name === cover.title)[0].key}`"
                     slot="header" />
          <com-title :title="cover.title + '筛选'"
                     to-text="全部"
                     :to="`category-type?page_type=${types.filter(el => el.name === cover.title)[0].key}`"
                     slot="header-classify" />
        </card-content>
      </a-layout-content>
      <com-footer></com-footer>
    </a-layout>
</template>

<script>

import cardContent from '../components/cart-content'
import comTitle from '../components/com-title'
import comUp from '../components/com-up'
export default {

  key(route) {
    return route.fullPath
  },

  head() {
    return {
      title: '首页',
      meta: [
        {
          hid: 'description',
          name: 'description',
          content: 'My custom description'
        }
      ],

    }
  },

  async asyncData({ route, redirect, $axios}) {
    const res = await $axios.get('/parse360/get_types_data', {
      params: {type: 'main',}
    })

    const category_type = await $axios.get('parse360/category_type?category=all')

    const res1 = await $axios.get('/parse360/category_type')

    // console.log(res, category_type, res1)
    return {
      content: (res.content || {}),
      classify_types: (res1.types || []),
      category_type: (category_type.types || []),
      page_type: 'main',
    }

    return {
      content: {},
      classify_types: [],
      category_type: [],
      page_type: 'main',
    }
  },

  data() {
    return {
      types: [
        {key: 'main', name: '首页', is_children: false},
        {key: 'serial', name: '电视剧', is_children: true},
        {key: 'film', name: '电影', is_children: true},
        {key: 'variety', name: '综艺', is_children: true},
        {key: 'cartoon', name: '动漫世界', is_children: true},
      ]
    }
  },

  mounted() {
  },

  methods: {}
}
</script>

